#include using namespace std; int stringLength(char s[]) { int result = 0; while(s[result] != '\0') { result++; } return result; } bool isStringEmpty(char s[]) { return (s[0] == '\0'); } bool stringCompare(char s1[], char s2[]) { bool result = true; if(strlen(s1) != strlen(s2)) { result = false; } int i; for(i = 0; s1[i] != '\0' && s2[i] != '\0' && result ; i++) { if(s1[i] != s2[i]) { result = false; } } return result; } bool stringICompare(char s1[], char s2[]) { bool result = true; if(strlen(s1) != strlen(s2)) { result = false; } int i; for(i = 0; s1[i] != '\0' && s2[i] != '\0' && result ; i++) { char c1 = s1[i]; char c2 = s2[i]; if(c1 >= 'a' && c1 <= 'z') { c1 = c1 - 32; } if(c2 >= 'a' && c2 <= 'z') { c2 = c2 - 32; } if(c1 != c2) { result = false; } } return result; } void stringCopy(char destination[],char source[]) { int i = 0; do { destination[i] = source[i]; i++; } while(destination[i-1] != '\0'); } void stringCat(char destination[],char source[]) { int length = strlen(destination); int i = 0; do { destination[i+length] = source[i]; i++; } while(destination[i+length-1] != '\0'); } void main() { //char name[5] = {'D','a','n','a'}; //char name2[5] = "Dana"; //int junk[4] = {1,2,3,4}; //char longName[10]; //cout << junk << endl; //cout << name << endl; //cout << name2 << endl; ////stream extraction operator >> stops at first whitespace, has no bounds checking, skips leading ws //cin >> longName; //cout << longName << endl; ////cin >> longName; ////cout << longName << endl; ////cin >> longName; ////cout << longName << endl; ////int x; ////cin >> x; // //cin.ignore(1); //cin.getline(longName,10); //cout << longName << endl; //cout << stringLength(longName) << endl; //cout << strlen(longName) << endl; char s1[100]; char s2[100]; cin >> s1; cin >> s2; //strlen //strcmp //stricmp //strncmp //strnicmp //strcpy //strncpy - the \0 is not copied //strcat if(strnicmp(s1,s2,3) == 0) { cout << "Same" << endl; } else { cout << "Different" << endl; } char s3[10]; //stringCopy(s3,s1); strcpy(s3,s1); stringCat(s3," "); //stringCat(s3,s2); strcat(s3,s2); cout << s3 << endl; //s3 = s1; }